<?php
require_once('../config/auth.php');
require_once('departement.cl.php');
$__CURRENT_PAGE__ = 'departement';
$__TITLE__ ="Formulaire d'ajouter un departement";
$departement = new Departement();
$departements = $departement->getAllDepartements();
$message = '';
if(count($_POST) > 0 ) {
  $departementData = $departement->save($_POST);
    if(!$departement->hasError()) {
        $message = "<div class='alert alert-success'>Departement sauvegardés avec succès</div>";
    }
}
elseif(!empty($_GET['id'])) {
    $departement->loadDepartementById($_GET['id']);
}
 require_once(dirname(__FILE__).'/../config/head.php');
?>
<body>
<?php require_once(dirname(__FILE__).'/../config/menu.php'); ?>
<div class="container ">
 <h1>Ajouter un departement</h1>
 <?php echo $message ?>
 <form method="post">
 	<input type="hidden" name="id" value="<?php echo $departement->getId() ?>" />
  <div class="row">
    <div class="span4">
         <label>Nom:</label>
         <input type="text" name="name" size="50" maxlength="50" value="<?php echo $departement->getName() ?>">
         <?php echo $departement->getError('name') ?>
    </div>
    <div class="span4">
         <label>Abreviation:</label>
         <input type="text" name="abreviation" size="50" maxlength="50" value="<?php echo $departement->getAbreviation() ?>">
         <?php echo $departement->getError('abreviation') ?>
     </div>
  </div>

  <div class="row">
     <div class="span2">
         <input type="reset" value="Annuler" class="btn btn-large btn-block">
     </div>
     <div class="span2 offset3">
         <input type="submit" value="Valider" class="btn btn-success btn-large btn-block">
     </div>
 </div>
 </form>
</div>
</body>
